package com.oneraku.service.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.oneraku.service.domain.WorkOrder;
import com.oneraku.service.utils.SixTwoRadixDigitsUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @Author: hui.ren@huberbuy.com
 * @Date: 2020/3/11 16:31
 */
@Slf4j
@Component
public class WorkOrderNameMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        Object originalObject = metaObject.getOriginalObject();
        if(originalObject instanceof WorkOrder){
            WorkOrder workOrder = (WorkOrder)originalObject;
            String id = workOrder.getId();
            this.setFieldValByName("name", SixTwoRadixDigitsUtils.to62RadixString(Long.valueOf(id)), metaObject);
        }
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
